package com.ruoyi.config.util.gaode.eunm;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description: 地理编码URL枚举
 * @Title: routePlanUrlConstant
 * @Package com.sxskz.software.base.gaud.routeplan.constant
 * @Author ZhangKeChen  🤙🤙🏼🤙🏽
 * @Date 2023/5/16 3:22 PM
 */
@Getter
@AllArgsConstructor
public enum GeoCodeUrlEnum {

    /**
     * 地理编码
     */
    GEO_CODE("Geo", "https://restapi.amap.com/v3/geocode/geo?key=%s&address=%s", "GET");

    /**
     * 高德API类型
     */
    String RoutePlanType;

    /**
     * 地理编码请求URL
     */
    String RoutePlanURL;

    /**
     * 地理编码URL请求方法
     */
    String RoutePlanURLRequestMethod;


    /**
     * 通过枚举的RoutePlanType，获取RoutePlanURL
     *
     * @param RoutePlanType
     * @return
     */
    public static String getRoutePlanURLByRoutePlanType(String RoutePlanType) {
        GeoCodeUrlEnum[] routePlanUrlEnums = values();
        for (GeoCodeUrlEnum routePlanUrlEnum : routePlanUrlEnums) {
            if (routePlanUrlEnum.getRoutePlanType().equals(RoutePlanType)) {
                return routePlanUrlEnum.getRoutePlanURL();
            }
        }
        throw new RuntimeException("高德key类型错误");
    }

    /**
     * 通过枚举的RoutePlanType，获取RoutePlanURLRequestMethod
     *
     * @param RoutePlanType
     * @return
     */
    public static String getRoutePlanURLRequestMethodByRoutePlanType(String RoutePlanType) {
        GeoCodeUrlEnum[] routePlanUrlEnums = values();
        for (GeoCodeUrlEnum routePlanUrlEnum : routePlanUrlEnums) {
            if (routePlanUrlEnum.getRoutePlanType().equals(RoutePlanType)) {
                return routePlanUrlEnum.getRoutePlanURLRequestMethod();
            }
        }
        throw new RuntimeException("高德key类型错误");
    }
}
